package daobeauty.test.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.Query;

import daobeauty.dao.Limiting;
import daobeauty.dao.Sorting;
import daobeauty.test.domain.D2;

/**
 * Created 12.09.2008
 * @author M. Serhat Cinar
 *
 */
public interface D2Dao{
	public Class getDomain();
	public Class<? extends Serializable> getPrimaryKey();
	
	// PK
	public D2 findById(Long id);
	public D2 findByPrimaryKey(Long id);

	// CRUD
	public void saveOrUpdate(D2 d2);
	public void save(D2 d2);
	public void delete(D2 d2);
	public void update(D2 d2);

	// helpers
	public Query getNamedQuery(String query);
	public Criteria createCriteria();

	public List<D2> findByExample(D2 example);
	public List<D2> findByExample(D2 example, Sorting sorting);
	public List<D2> findByExample(D2 example, Sorting sorting, Limiting limit);
	public List<D2> findByExample(D2 example, Limiting limit);
	
	public List<D2> findAll();
	public List<D2> findAll(String hql, Object[] parameters);
	public List<D2> findAll(String hql, Collection parameters);
	public List<D2> findAll(String hql, Map<String, Object> namedParameters);
	
	public List<D2> myNamedQuery();
	
	// This method is not available in any supplied Delegate and must cause errors
	public D2 findByHighestId();

	public List<D2> findByNameAndSubject(String name, String subject);
	public List<D2> findByNameILikeAndSubjectIsNull(String name);
	public List<D2> findByFirstAndLastName(String name);
	public List<D2> findByNameAndSubject(String name, String subject, Sorting sorting, Limiting limiting);
	public List<D2> findByNameIsNotNull(Sorting sorting, Limiting limiting);
	public Object[] findBySubjectIsNotNull();
	
	public List findByNativeQuery(String sql);
	public List findByNativeQuery(String sql, Object[] parameters);
	public List findByNativeQuery(String sql, Map<String, Object> parameters);
}
